import { translate, setupLanguage } from './i18n';

remoteChannel.onServerEvent(async ({ entity, args, tick }) => {
    if (args === "play") {
        entity.player.cameraMode = GameCameraMode.FPS
        
        // 让玩家选择语言
        await setupLanguage(entity);
        
        await entity.player.dialog({
            type: GameDialogType.TEXT,
            title: translate('温馨提醒', entity.language),
            content: `${translate('若有不适请立即退出地图', entity.language)}
        ${translate('如果觉得暗，请在画面设置中调高伽马', entity.language)}`,
        })
        
        const do_you = await entity.player.dialog({
            type: GameDialogType.SELECT,
            title: translate('视角选择', entity.language),
            content: `${translate('选项：', entity.language)}
        ${translate('你晕3D吗？', entity.language)}`,
            options: [translate('晕', entity.language), translate('不晕', entity.language)]
        })
        
        if (!do_you || do_you == null) return;
        switch (do_you.value) {
            case translate('晕', entity.language):
                entity.player.cameraFovY = 0.25;//关闭广角
                break;
            case translate('不晕', entity.language):
                entity.player.cameraFovY = 20.5;//开启广角
                break;
            default:
                break;
        }
        
        await entity.player.dialog({
            type: GameDialogType.TEXT,
            title: translate('特别鸣谢', entity.language),
            content: translate('@符华（283432408095765）的后室-研究人员（模型）\n@坦率的血翼蝠5801（12823830）的代码\n@EMO屑幽幽（@屑夜awa：50087305）的恐怖爷爷、恐怖奶奶、兰德里纳河（模型）\n@吉吉喵（455） 的搬运\n@搬砖喵（85487）的创作端修复\n@暗23（50480768）和@元元BU1e（13306211）的合作辅助\n以及其他，更多，如果你的信息没有记在上面，请在评论区申诉给我们', entity.language),
        })
        
        await entity.player.dialog({
            type: GameDialogType.TEXT,
            content: translate('第{day}天', entity.language, { day: entity.day }),
        })
    } else if (args === "quit") {
        await entity.player.dialog({
            type: GameDialogType.TEXT,
            title: translate('温馨提示', entity.language),
            content: translate('感谢您的游玩，期待您的再次光临！', entity.language),
        });
        entity.player.kick();
    } else if (args === "Radiation") {
        entity.player.link('https://dao3.fun/profile/383007848477925', { isConfirm: false, isNewTab: true });
    }
});